<template>
  <div class="home-welcome">
    <h2>欢迎使用临安区公共机构资源能耗统计管理系统</h2>
    <div class="addUser-listBox">
      <div class="addUser-listRow">
        <div class="addUser-listCol1">
          <p>登录账户：</p>
        </div>
        <div class="addUser-listCol2">
          <span>{{(userInfo&&userInfo.name)?userInfo.name:''}}</span>
        </div>
      </div>
      <div class="addUser-listRow">
        <div class="addUser-listCol1">
          <p>IP地址：</p>
        </div>
        <div class="addUser-listCol2">
          <span>112.17.112.137</span>
        </div>
      </div>
      <div class="addUser-listRow">
        <div class="addUser-listCol1">
          <p>当前时间：</p>
        </div>
        <div class="addUser-listCol2">
          <span>{{nowTime|datetime('yyyy年MM月dd日 hh:mm:ss')}}</span>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      userInfo: {},
      nowTime: new Date()
    }
  },
  methods: {
    setTime() {
      setInterval(() => {
        this.nowTime = new Date()
      }, 1000)
    }
  },
  created() {
    this.setTime()
    try {
      this.userInfo = JSON.parse(localStorage.getItem("userInfo"))
    } catch (error) {

    }
  }
}
</script>
<style lang="scss" scoped>
.home-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  width: 100%;
  padding: 0 15px;
  background-color: #fff;
  h2 {
    height: 120px;
    width: 100%;
    font-size: 20px;
    line-height: 120px;
    text-align: center;
  }
}

.addUser-listBox {
  width: 100%;
  border: 1px solid #dcdfe6;
  border-bottom: none;
  border-top-right-radius: 5px;
  border-top-left-radius: 5px;
  display: flex;
  flex-direction: column;
  .addUser-listRow {
    height: 40px;
    display: flex;
    flex-direction: row;
    align-items: center;
    border-bottom: 1px solid #dcdfe6;
    .addUser-listCol1 {
      display: flex;
      flex-direction: row;
      flex: 1;
      height: 40px;
      align-items: center;
      justify-content: flex-end;
      color: darkgray;
    }
    .addUser-listCol2 {
      display: flex;
      height: 40px;
      border-left: 1px solid #dcdfe6;
      align-items: center;
      flex-direction: row;
      flex: 1.2;
      padding-left: 8px;
      span {
        margin-left: 5px;
        font-size: 16px;
      }
    }
  }
}
</style>